import { request, requestMock } from "@/utils/http";
/** @navTypeListRequest 获取类型列表的请求 @return 返回请求的结果 @params 没有参数 */
export const navTypeListRequest = () => {
  return request.get("/api/product/getBaseCategoryList");
};
/** @bannerListRequest 获取轮播图列表的请求 */
export const bannerListRequest = () => {
  return requestMock.get("/banner");
};

/** @floorListRequest 获取楼层列表的请求 */
export const floorListRequest = () => {
  return requestMock.get("/floor");
};

/** @searchListRequest 获取搜索列表的请求 */
export const searchListRequest = (params) => {
  return request.post("/api/list", params);
};

/**@goodsDetailRequest 获取商品详情的请求 */
export const goodsDetailRequest = (skuId) => {
  return request.get(`/api/item/${skuId}`);
};

/**@addOfUpdateCartRequest 添加商品到购物车或者修改购物车数量 的请求 */
export const addOfUpdateCartRequest = ({ skuId, skuNum }) => {
  return request.post(`/api/cart/addToCart/${skuId}/${skuNum}`);
};

/**@getCartListRequest 请求购物车数据的请求 */
export const getCartListRequest = () => {
  return request.get("/api/cart/cartList");
};

/**@singleCheckedRequest 购物车数据单选的请求 */
export const singleCheckedRequest = (skuId, isChecked) => {
  return request.get(`/api/cart/checkCart/${skuId}/${isChecked}`);
};

/**@allCheckedRequest 购物车数据全选的请求 */
export const allCheckedRequest = (isChecked, skuIdList) => {
  return request.post(`/api/cart/batchCheckCart/${isChecked}`, skuIdList);
};

/**@singleDeleteRequest 购物车数据删除的请求 */
export const singleDeleteRequest = (skuId) => {
  return request.delete(`/api/cart/deleteCart/${skuId}`);
};

/**@batchDeleteRequest 购物车数据删除的请求 */
export const batchDeleteRequest = (skuIdList) => {
  return request.delete("/api/cart/batchDeleteCart", {
    data: skuIdList,
  });
};

/**@getVerifyCodeRequest 获取验证码的请求 */
export const getVerifyCodeRequest = (phone) => {
  return request.get(`/api/user/passport/sendCode/${phone}`);
};

/**@registerRequest 用户注册的请求 */
export const registerRequest = (userInfo) => {
  return request.post("/api/user/passport/register", userInfo);
};

/**@loginRequest 用户登陆的请求 */
export const loginRequest = (userInfo) => {
  return request.post("/api/user/passport/login", userInfo);
};
/**@getUserInfoByTokenRequest 通过token获取用户信息 */
export const getUserInfoByTokenRequest = () => {
  return request.get("/api/user/passport/auth/getUserInfo");
};

/**@logoutRequest 退出登录的请求 */
export const logoutRequest = () => {
  return request.get("/api/user/passport/logout");
};

/**@getTradeInfoRequest 请求交易页信息的请求 */
export const getTradeInfoRequest = () => {
  return request.get("/api/order/auth/trade");
};

/**@getAddressRequest 请求交易页地址的请求 */
export const getAddressRequest = () => {
  return requestMock.get("/address");
};

/**@submitOrderRequest 提交订单的请求 */
export const submitOrderRequest = (tradeNo, tradeNoInfo) => {
  return request.post(
    `/api/order/auth/submitOrder?tradeNo=${tradeNo}`,
    tradeNoInfo
  );
};

/**@getOrderInfoRequest 订单支付信息的请求 */
export const getOrderInfoRequest = (orderId) => {
  return request.get(`/api/payment/weixin/createNative/${orderId}`);
};

/**@queryPayStatusRequest 查询支付的状态请求 */
export const queryPayStatusRequest = (orderId) => {
  return request.get(`/api/payment/weixin/queryPayStatus/${orderId}`);
};

/**@queryPayStatusRequest 查询支付的状态请求 */
export const getOrderListRequest = ({page,limit}) => {
  return request.get(`/api/order/auth/${page}/${limit}`);
};


